package com.lxw.study.structural.proxy.dynamicproxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class Client {
    public static void main(String[] args) {
        RealSubject target = new RealSubject();
        InvocationHandler invocationHandler = (proxy1, method, args1) -> {
            System.out.println("before...");
            Object result = method.invoke(target, args1);
            System.out.println("after...");
            return result;
        };
        Subject subjectProxy = (Subject) Proxy.newProxyInstance(Subject.class.getClassLoader(),
                RealSubject.class.getInterfaces(), invocationHandler);
        subjectProxy.request();
    }


}
